<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=iso-8859-1" />
    <title>
      Xorg-7 Testing and Configuration
    </title>
    <link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
  </head>
  <body class="blfs" id="blfs-2020-04-02">
    <div class="navheader">
      <h4>
        Beyond Linux<sup>�</sup> From Scratch <span class="phrase">(System
        V</span> Edition) - Version 2020-04-02
      </h4>
      <h3>
        Chapter&nbsp;24.&nbsp;X Window System Environment
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="xinit.html" title="xinit-1.4.1">Prev</a>
          <p>
            xinit-1.4.1
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="tuning-fontconfig.html" title=
          "Tuning Fontconfig">Next</a>
          <p>
            Tuning Fontconfig
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="installing.html" title=
          "Chapter&nbsp;24.&nbsp;X Window System Environment">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="xorg-config" name="xorg-config"></a>Xorg-7 Testing and
        Configuration
      </h1>
      <div class="sect2" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="X11-testing" name="X11-testing"></a>Testing Xorg
        </h2>
        <div class="admon note">
          <img alt="[Note]" src="../images/note.png" />
          <h3>
            Note
          </h3>
          <p>
            Before starting Xorg for the first time, is is useful to rebuild
            the library cache by running <strong class=
            "userinput"><code>ldconfig</code></strong> as the <code class=
            "systemitem">root</code> user.
          </p>
        </div>
        <div class="admon note">
          <img alt="[Note]" src="../images/note.png" />
          <h3>
            Note
          </h3>
          <p>
            Before starting Xorg for the first time, is is often needed to
            reboot the system to ensure all appropriate daemons are started
            and approprite security issues are properly set. As an
            alternative, logging out and logging back in may work, but as of
            this writing has not been tested.
          </p>
        </div>
        <p>
          To test the <span class="application">Xorg</span> installation,
          issue <span class="command"><strong>startx</strong></span>. This
          command brings up a rudimentary window manager called <span class=
          "emphasis"><em>twm</em></span> with three xterm windows and one
          xclock window. The xterm window in the upper left is a login
          terminal and running <span class="emphasis"><em>exit</em></span>
          from this terminal will exit the <span class="application">X
          Window</span> session. The third xterm window may be obscured on
          your system by the other two xterms.
        </p>
        <div class="admon note">
          <img alt="[Note]" src="../images/note.png" />
          <h3>
            Note
          </h3>
          <p>
            When testing <span class="application">Xorg</span> with the
            <span class="application">twm</span> window manager, there will
            be several warnings in the Xorg log file,
            $HOME/.local/share/xorg/Xorg.0.log, about missing font files. In
            addition, there will be several warnings on the text mode
            terminal (usually tty1) about missing fonts. These warnings do
            not affect functionality, but can be removed if desired by
            installing the <a class="xref" href="x7legacy.html" title=
            "Xorg Legacy">Xorg Legacy Fonts</a>.
          </p>
        </div>
        <p>
          Generally, there is no specific configuration required for
          <span class="application">Xorg</span>, but customization is
          possible. For details, see <a class="xref" href=
          "xorg-config.html#xconfig" title="Setting up Xorg Devices">the
          section called &ldquo;Setting up Xorg Devices&rdquo;</a> below.
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="checking-dri" name="checking-dri"></a>Checking the Direct
          Rendering Infrastructure (DRI) Installation
        </h2>
        <p>
          DRI is a framework for allowing software to access graphics
          hardware in a safe and efficient manner. It is installed in
          <span class="application">X</span> by default (using <span class=
          "application">Mesa</span>) if you have a supported video card.
        </p>
        <p>
          To check if DRI drivers are installed properly, check the log file
          <code class="filename">$HOME/.local/share/xorg/Xorg.0.log</code>
          (or <code class="filename">/var/log/Xorg.0.log</code> if you have
          built <a class="xref" href="xorg-server.html" title=
          "Xorg-Server-1.20.8">Xorg-Server-1.20.8</a> with the suid bit) for
          statements such as:
        </p>
        <pre class="screen">
<code class="literal">(II) intel(0): direct rendering: DRI2 Enabled</code>
</pre>
        <p>
          or
        </p>
        <pre class="screen">
<code class="literal">(II) NOUVEAU(0): Loaded DRI module</code>
</pre>
        <div class="admon note">
          <img alt="[Note]" src="../images/note.png" />
          <h3>
            Note
          </h3>
          <p>
            DRI configuration may differ if you are using alternate drivers,
            such as those from <a class="ulink" href=
            "http://www.nvidia.com/page/home.html">NVIDIA</a> or <a class=
            "ulink" href="http://www.amd.com/">AMD</a>.
          </p>
        </div>
        <p>
          Another way to determine if DRI is working properly is to use one
          of the two optionally installed OpenGL demo programs in <a class=
          "xref" href="mesa.html" title="Mesa-20.0.2">Mesa-20.0.2</a>. From
          an X terminal, run <span class=
          "command"><strong>glxinfo</strong></span> and look for the phrase:
        </p>
        <pre class="screen">
<code class="computeroutput">name of display: :0
display: :0  screen: 0
direct rendering: Yes</code>
</pre>
        <p>
          If direct rendering is enabled, you can add verbosity by running
          <span class="command"><strong>LIBGL_DEBUG=verbose
          glxinfo</strong></span>. This will show the drivers, device nodes
          and files used by the DRI system.
        </p>
        <p>
          To confirm that DRI2 hardware acceleration is working, you can
          (still in the X terminal) run the command <span class=
          "command"><strong>glxinfo | egrep "(OpenGL vendor|OpenGL
          renderer|OpenGL version)"</strong></span>. If that reports
          something <span class="emphasis"><em>other than</em></span>
          <code class="literal">Software Rasterizer</code> then you have
          working acceleration for the user who ran the command.
        </p>
        <p>
          If your hardware does not have any DRI2 driver available, it will
          use a Software Rasterizer for Direct Rendering. In such cases, you
          can use a new, LLVM-accelerated, Software Rasterizer called
          LLVMPipe. In order to build LLVMPipe just make sure that <a class=
          "xref" href="../general/llvm.html" title=
          "LLVM-10.0.0">LLVM-10.0.0</a> is present at Mesa build time. Note
          that all decoding is done on the CPU instead of the GPU, so the
          display will run slower than with hardware acceleration. To check
          if you are using LLVMpipe, review the output of the glxinfo command
          above. An example of the output using the Software Rasterizer is
          shown below:
        </p>
        <pre class="screen">
<code class="computeroutput">OpenGL vendor string: VMware, Inc.
OpenGL renderer string: Gallium 0.4 on llvmpipe (LLVM 3.5, 256 bits)
OpenGL version string: 3.0 Mesa 10.4.5</code>
</pre>
        <p>
          You can also force LLVMPipe by exporting the <code class=
          "envar">LIBGL_ALWAYS_SOFTWARE=1</code> environment variable when
          starting Xorg.
        </p>
        <p>
          Again, if you have built the Mesa OpenGL demos, you can also run
          the test program <span class=
          "command"><strong>glxgears</strong></span>. This program brings up
          a window with three gears turning. The X terminal will display how
          many frames were drawn every five seconds, so this will give a
          rough benchmark. The window is scalable, and the frames drawn per
          second is highly dependent on the size of the window. On some
          hardware, <span class="command"><strong>glxgears</strong></span>
          will run synchronized with the vertical refresh signal and the
          frame rate will be approximately the same as the monitor refresh
          rate.
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="hybrid-graphics" name="hybrid-graphics"></a>Hybrid Graphics
        </h2>
        <p>
          Hybrid Graphics is still in experimental state for Linux. Xorg
          Developers have developed a technology called PRIME that can be
          used for switching between integrated and muxless discrete GPU at
          will. Automatic switching is not possible at the moment.
        </p>
        <p>
          In order to use PRIME for GPU switching, make sure that you are
          using Linux Kernel 3.4 or later (recommended). You will need latest
          DRI and DDX drivers for your hardware and <span class=
          "application">Xorg Server</span> 1.13 or later.
        </p>
        <p>
          <span class="application">Xorg Server</span> should load both GPU
          drivers automaticaly. You can check that by running:
        </p>
        <pre class="userinput">
<kbd class="command">xrandr --listproviders</kbd>
</pre>
        <p>
          There should be two (or more) providers listed, for example:
        </p>
        <pre class="screen">
<code class="computeroutput">Providers: number : 2
Provider 0: id: 0x7d cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 3 outputs: 4 associated providers: 1 name:Intel
Provider 1: id: 0x56 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 6 outputs: 1 associated providers: 1 name:radeon</code>
</pre>
        <p>
          In order to be able to run a GLX application on a discrete GPU, you
          will need to run the following command, where &lt;provider&gt; is
          the more powerful discrete card, and &lt;sink&gt; is the card which
          has a display connected:
        </p>
        <pre class="userinput">
<kbd class="command">xrandr --setprovideroffloadsink <em class=
"replaceable"><code>&lt;provider&gt; &lt;sink&gt;</code></em></kbd>
</pre>
        <div class="admon note">
          <img alt="[Note]" src="../images/note.png" />
          <h3>
            Note
          </h3>
          <p>
            With newer <span class="application">Xorg</span> drivers, such as
            modesetting or intel, which are DRI3 capable, the above command
            is no longer necessary. It does no harm however.
          </p>
        </div>
        <p>
          Then, you will need to export the <code class=
          "envar">DRI_PRIME=1</code> environment variable each time you want
          the powerful GPU to be used. For example,
        </p>
        <pre class="userinput">
<kbd class=
"command">DRI_PRIME=1 glxinfo | egrep "(OpenGL vendor|OpenGL renderer|OpenGL version)"</kbd>
</pre>
        <p>
          will show OpenGL vendor, renderer and version for the discrete GPU.
        </p>
        <p>
          If the last command reports same OpenGL renderer with and without
          <code class="envar">DRI_PRIME=1</code>, you will need to check your
          installation.
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="xconfig" name="xconfig"></a>Setting up Xorg Devices
        </h2>
        <p>
          For most hardware configurations, modern Xorg will automatically
          get the server configuration correct without any user intervention.
          There are, however, some cases where auto-configuration will be
          incorrect. Following are some example manual configuration items
          that may be of use in these instances.
        </p>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3">
            <a id="xinput" name="xinput"></a>
          </h3>
          <h4 class="title">
            <a id="xinput" name="xinput"></a>Setting up X Input Devices
          </h4>
          <p>
            For most input devices, no additional configuration will be
            necessary. This section is provided for informational purposes
            only.
          </p>
          <p>
            A sample default XKB setup could look like the following
            (executed as the <code class="systemitem">root</code> user):
          </p>
          <pre class="root">
<kbd class=
"command">cat &gt; /etc/X11/xorg.conf.d/xkb-defaults.conf &lt;&lt; "EOF"
<code class="literal">Section "InputClass"
    Identifier "XKB Defaults"
    MatchIsKeyboard "yes"
    Option "XkbLayout" "fr"
    Option "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection</code>
EOF</kbd>
</pre>
          <p>
            The <span class="quote">&ldquo;<span class=
            "quote">XkbLayout</span>&rdquo;</span> line is an example for a
            French (AZERTY) keyboard. Change it to your keyboard model. That
            line is not needed for a QWERTY (US) keyboard.
          </p>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3">
            <a id="xdisplay" name="xdisplay"></a>
          </h3>
          <h4 class="title">
            <a id="xdisplay" name="xdisplay"></a>Fine Tuning Display Settings
          </h4>
          <p>
            Again, with modern Xorg, little or no additional configuration is
            necessary. If you should need extra options passed to your video
            driver, for instance, you could use something like the following
            (again, executed as the <code class="systemitem">root</code>
            user):
          </p>
          <pre class="root">
<kbd class=
"command">cat &gt; /etc/X11/xorg.conf.d/videocard-0.conf &lt;&lt; "EOF"
<code class="literal">Section "Device"
    Identifier  "Videocard0"
    Driver      "radeon"
    VendorName  "Videocard vendor"
    BoardName   "ATI Radeon 7500"
    Option      "NoAccel" "true"
EndSection</code>
EOF</kbd>
</pre>
          <p>
            Another common setup is having multiple server layouts for use in
            different environments. Though the server will automatically
            detect the presence of another monitor, it may get the order
            incorrect:
          </p>
          <pre class="root">
<kbd class=
"command">cat &gt; /etc/X11/xorg.conf.d/server-layout.conf &lt;&lt; "EOF"
<code class="literal">Section "ServerLayout"
    Identifier     "DefaultLayout"
    Screen      0  "Screen0" 0 0
    Screen      1  "Screen1" LeftOf "Screen0"
    Option         "Xinerama"
EndSection</code>
EOF</kbd>
</pre>
        </div>
      </div>
      <p class="updated">
        Last updated on 2020-03-22 03:34:34 -0500
      </p>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="xinit.html" title="xinit-1.4.1">Prev</a>
          <p>
            xinit-1.4.1
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="tuning-fontconfig.html" title=
          "Tuning Fontconfig">Next</a>
          <p>
            Tuning Fontconfig
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="installing.html" title=
          "Chapter&nbsp;24.&nbsp;X Window System Environment">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
  </body>
</html>
